public class Processor {
    private static int cycleNumber = 0;
    private static int endSwitch = 0;
    private ProcessorManager pManager;
    private Job currJob;
    
    public Processor(ProcessorManager p) {
        pManager = p;
    }
    public Job getCurrJob(){
        return currJob;
    }
    public void setCurrJob(Job j){
      currJob = j;
      pManager.getPScheduler().setRunningStatus(currJob);
    }
    public static int getCycleNumber(){
      return cycleNumber;
    }
    public void processJob(Job j){
        pManager.getPScheduler().bringJob(j);
        
        for(int i=0;i<j.getPCB().getAccounting().calcTime(); i++){
          j.getPCB().setRegCounter(j.getPCB().getRegCounter()+1);
        }
        pManager.getPScheduler().jobFinished(j);
    }
    public void cycle(){
      currJob.getPCB().setRegCounter(currJob.getPCB().getRegCounter()+1);
      cycleNumber++;
      if(currJob.getPCB().getRegCounter() == currJob.getPCB().getAccounting().calcTime() || cycleNumber - endSwitch == 20){
        pManager.getPScheduler().switchJobs();
        endSwitch = cycleNumber;
      }
    }
}